import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'amfe-flexible'
import { DatetimePicker, Image, CellGroup, Tag, Badge, Search, Row, Col, NavBar, Divider, Form, Popup, Field, Button, Tabbar, TabbarItem, Icon, Tab, Tabs, Cell, List, PullRefresh, ActionSheet, Dialog } from 'vant'
// 调用时直接在input或textarea标签上添加v-focus指令
Vue.directive('focus', { // 全局注册自定义指令
  inserted (el) {
    if (['INPUT', 'TEXTAREA'].indexOf(el.tagName) !== -1) {
      el.focus()
    } else {
      let node = el.querySelector('input')
      if (node) {
        node.focus()
        return
      }
      node = el.querySelector('textarea')
      if (node) {
        node.focus()
        return
      }
      throw new Error('请把v-focus指令用到input或textarea上')
    }
  }
})
Vue.use(DatetimePicker)
Vue.use(Image)
Vue.use(CellGroup)
Vue.use(Tag)
Vue.use(NavBar)
Vue.use(Form)
Vue.use(Field)
Vue.use(Button)
Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Icon)
Vue.use(Tab)
Vue.use(Tabs)
Vue.use(Cell)
Vue.use(List)
Vue.use(PullRefresh)
Vue.use(ActionSheet)
Vue.use(Dialog)
Vue.use(Popup)
Vue.use(Badge)
Vue.use(Row)
Vue.use(Col)
Vue.use(Search)
Vue.use(Divider)
Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
